package org.siqisource.webstart.core.widgets.tree.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public abstract class AbstractTreeConfig implements TreeConfig {

	private List<String> otherFields;

	private List<String> otherProperties;

	public AbstractTreeConfig() {
		prepareOthers(initFieldMapping());
	}

	public abstract HashMap<String, String> initFieldMapping();

	public void prepareOthers(HashMap<String, String> fieldMapping) {
		if (fieldMapping != null) {
			Set<String> properties = fieldMapping.keySet();
			if (properties.size() > 0) {
				Iterator<String> it = fieldMapping.keySet().iterator();
				this.otherProperties = new ArrayList<String>();
				this.otherFields = new ArrayList<String>();
				while (it.hasNext()) {
					String property = it.next();
					this.otherProperties.add(property);
					this.otherFields.add(fieldMapping.get(property));
				}
			}
		}
	}

	public List<String> getOtherFields() {

		return this.otherFields;
	}

	public List<String> getOtherProperties() {
		return this.otherProperties;
	}
}
